<?php
class buycc
{
	public static function findagent()
	{
		$GetAgent=database::LimitQuery('agent',array(
		'select' => 'agent_name,agent_class',
		'condition' => array(
		'enable' => 'Y',
		'agent_type' => 'cc'
		)
		));
		return $GetAgent;
	}
	public static function GetMaxId($Table,$Column,$Condition)
	{
		$Sql="select max($Column) from $Table where $Condition";
		$Result=database::GetQueryResult($Sql,0);
		foreach($Result as $ShowResult)
		{
			$max="max($Column)";
			$Id=$ShowResult["$max"];
		}
		$IdReturn=$Id;
		return $IdReturn;
	}
	public static function returnPrice($ccid)
	{
		$getPrice=database::LimitQuery("ccinfo",array(
		'select' => 'price',
		'condition' => array(
		'ccid' => $ccid
		)
		));
		return $getPrice[0]['price'];
	}
	public static function unhashBase64($plan,$array)
	{
		$i=0;
		if(($plan=="dimitry")||($plan=="keyvnc")||($plan=='mrhieu'))
		{
			$arrayReturn=array();
			foreach($array as $list)
			{
				$arrayReturn[$i]['firstname']=base64_decode($list['firstname']);
				$arrayReturn[$i]['ccid']=$list['ccid'];
				$arrayReturn[$i]['typecc']=$list['typecc'];
				$arrayReturn[$i]['lastname']=base64_decode($list['lastname']);
				$arrayReturn[$i]['ccnumber']=$list['ccnumber'];
				$arrayReturn[$i]['exmonth']=$list['exmonth'];
				$arrayReturn[$i]['exyear']=$list['exyear'];
				$arrayReturn[$i]['ccv2']=$list['ccv2'];
				$arrayReturn[$i]['address']=base64_decode($list['address']);
				$arrayReturn[$i]['city']=base64_decode($list['city']);
				$arrayReturn[$i]['state']=base64_decode($list['state']);
				$arrayReturn[$i]['zip']=base64_decode($list['zip']);
				$arrayReturn[$i]['phone']=$list['phone'];
				$arrayReturn[$i]['country']=base64_decode($list['country']);
				$arrayReturn[$i]['dob']=base64_decode($list['dob']);
				$arrayReturn[$i]['ssn']=base64_decode($list['ssn']);
				$arrayReturn[$i]['userid']=$list['userid'];
				$arrayReturn[$i]['orderid']=$list['orderid'];
				$arrayReturn[$i]['status']=$list['status'];
				$arrayReturn[$i]['pricesell']=$list['pricesell'];
				$arrayReturn[$i]['others']=base64_decode($list['others']);
				$i++;
			}
			unset($array);
			return $arrayReturn;
		}
		else
		{
			return $array;
		}
	}
	public static function SearchCC($Country,$Bin, $Type, $price,$agent)
	{
		$condition=NULL;
		if($Bin!=0)
		{
			$condition=$condition." and ccnumber like '$Bin%'";
		}
		else
		{
			if(!empty($Type))
			{
				$Bin=$Type;
				$condition=$condition." and ccnumber like '$Bin%'";
	
			}
		}
		$Country=base64_encode($Country);
		$condition="country='$Country' and site='$agent' and userid=0 and orderid=0".$condition;
		$getCcSql="select * from ccinfo where $condition order by rand() limit 0,40";
		$arrayReturn=database::GetQueryResult($getCcSql,"0");
		if(!empty($arrayReturn))
		{
			$i=0;
			foreach($arrayReturn as $return)
			{
				$arrReturn[$i]['bin']=substr($return['ccnumber'],0,6);
				$arrReturn[$i]['name']=base64_decode($return['firstname']);
				$arrReturn[$i]['exM']=$return['exmonth'];
				$arrReturn[$i]['exY']=$return['exyear'];
				$arrReturn[$i]['city']=base64_decode($return['city']);
				$arrReturn[$i]['state']=base64_decode($return['state']);
				$arrReturn[$i]['country']=base64_decode($return['country']);
				$arrReturn[$i]['zip']=base64_decode($return['zip']);
				$arrReturn[$i]['price']=$return['price'];
				$arrReturn[$i]['ccid']=$return['ccid'];
				$i++;
			}
			return $arrReturn;
		}
		else
		{
			return 0; // empty
		}
	
	}
	public static function findChecker($site)
	{
		$findChecker=database::LimitQuery("checker",array(
		'select' => 'id',
		'condition' => array(
		'site' => $site
		)
		));
		if(!empty($findChecker))
		{
			return $findChecker[0]['id'];
		}
		else
		{
			return 3;
		}
	}
}
?>